import './App.scss'

// 导入路由
import { Router, Route, Switch, Redirect } from 'react-router-dom'
import { customHistory } from '@/utils'
import { lazy, Suspense } from 'react'

// 导入页面组件
import Auth from '@/components/auth'
import { Spin } from 'antd'
// import Login from './pages/login'
// import Layout from './pages/layout'
// import NotFound from './pages/404'
// 懒加载
const Layout = lazy(() => import('./pages/layout'))
const Login = lazy(() => import('./pages/login'))
const NotFound = lazy(() => import('./pages/404'))

function App() {
  return (
    <Router history={customHistory}>
      {/* 使用 Suspense 包裹所有内容*/}
      <Suspense
        fallback={
          <div className="loading">
            <Spin tip="努力加载中..." />
          </div>
        }>
        <div className="app">
          <Switch>
            <Redirect exact from="/" to="/home" />
            {/* <Route path="/home" component={Layout}></Route> */}
            <Auth path="/home" component={Layout} meng="100000" />
            <Route path="/login" component={Login}></Route>
            {/* 404 */}
            <Route component={NotFound} />
          </Switch>
        </div>
      </Suspense>
    </Router>
  )
}

export default App
